<?php
	$picture = new Picture();	
	if (isset($picture_id)) {		
		$picture->select($picture_id);
		if (isset($delete) && $delete == 'yes') {
			$room = new Room();
			$room->select($room_id);
			$pictures = $room->getpictures();
			$pictures = json_decode($pictures, true);
			foreach ($pictures as $index => $id)
				if ($picture->getid() == $id )
					unset($pictures[$index]);
			$pictures = json_encode($pictures);
			$room->setpictures($pictures);
			$room->update($room_id);
			$picture->deleteAllFiles();
			$picture->delete($picture_id);
			admin_load("Hình Đã Được Xoá Thành Công", "?act=pictures_list_for_room&room_id=$room_id");
		}
			
	}
	
	if ($picture || isset($add))
		include "tpl/edit_picture_form.php";
	else
		echo "Hình Ảnh Không Tồn Tại";
?>